package cn.com.chamc.soft2.riskdm.controller;

import java.io.IOException;

import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class FirstController {

	@Autowired
	Environment env;

	@Value("classpath:static\\json\\monk.json")
	private Resource monk;

	@RequestMapping("/index")
	public String index() {
		return "index";
	}

	@RequestMapping("/")
	public String blank() {
		return "index";
	}

	@RequestMapping("/wordcloud")
	public String wordcloud() {
		return "wordcloud";
	}

	@RequestMapping("/anime")
	public String anime() {
		return "anime";
	}

	@RequestMapping("/ajaxData01")
	public String ajaxData01() throws IOException {
		return readJsonResource(monk);
	}

	private String readJsonResource(Resource res) throws IOException {
		return IOUtils.toString(res.getInputStream(), "UTF-8");
	}

}
